package o;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import o.ddq.f;

public class ddw implements dmi {
    private Context ˋ;
    private b ˏ;
    private List<String> ॱ;

    public interface b {
        void ˎ(List<def> list);
    }

    public ddw(Context context, b bVar) {
        this.ˋ = context;
        this.ˏ = bVar;
    }

    public ddw(Context context, List<String> list, b bVar) {
        this.ˋ = context;
        this.ˏ = bVar;
        this.ॱ = list;
    }

    public void run() {
        List arrayList = new ArrayList();
        if (this.ॱ == null) {
            arrayList.addAll(((cdg) cdb.ॱ(cdg.class)).ʻ());
        } else {
            for (String ˏ : this.ॱ) {
                PackageInfo ˏ2 = dnx.ˏ(ˏ, this.ˋ);
                if (ˏ2 != null) {
                    arrayList.add(ˏ2);
                }
            }
        }
        List ˏ3 = ˏ(arrayList);
        if (this.ˏ != null) {
            this.ˏ.ˎ(ˏ3);
        }
    }

    private List<def> ˏ(List<PackageInfo> list) {
        List<def> arrayList = new ArrayList();
        PackageManager packageManager = this.ˋ.getPackageManager();
        for (PackageInfo packageInfo : list) {
            ApplicationInfo applicationInfo = packageInfo.applicationInfo;
            if (applicationInfo != null && applicationInfo.publicSourceDir.equals(applicationInfo.sourceDir)) {
                File file = new File(applicationInfo.publicSourceDir);
                if (file.canRead()) {
                    def o_def = new def();
                    o_def.ˊ(applicationInfo.packageName);
                    o_def.ˎ(applicationInfo.loadLabel(packageManager).toString());
                    o_def.ˋ(applicationInfo.loadIcon(packageManager));
                    o_def.ˏ(applicationInfo.publicSourceDir);
                    o_def.ॱ(epw.ˊ(file.length()));
                    o_def.ˋ(this.ˋ.getString(f.ʽॱ, new Object[]{packageInfo.versionName}));
                    arrayList.add(o_def);
                }
            }
        }
        return arrayList;
    }
}
